package com.org.gsc.chartdemo.activitys;

import android.graphics.Color;

import com.github.mikephil.charting.charts.BubbleChart;
import com.github.mikephil.charting.data.BubbleData;
import com.github.mikephil.charting.data.BubbleDataSet;
import com.github.mikephil.charting.data.BubbleEntry;
import com.github.mikephil.charting.interfaces.datasets.IBubbleDataSet;
import com.org.gsc.chartdemo.R;
import com.org.gsc.chartdemo.bases.BaseActivity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by qundui on 2017/10/9.
 * 气泡图
 */
public class BuddleActivity extends BaseActivity {
    private BubbleChart mBubbleChart;
    private List<IBubbleDataSet> mdatas;
    private BubbleDataSet m气泡图;
    private BubbleData mBubbleData;
    @Override
    protected void doBusy() {
        mdatas=new ArrayList<>();
        List<BubbleEntry> ys=new ArrayList<>();
        for (int i = 0; i < 20; i++) {
            float val = (float) (Math.random() * 40);
            float size = (float) (Math.random() * 50);

            ys.add(new BubbleEntry(i, val, size));
        }
//        ys.add(new BubbleEntry(0,20f,5.0f));
        //如果设置一个点半径设置无效
        m气泡图 = new BubbleDataSet(ys, "气泡图");
        m气泡图.setDrawIcons(false);
        m气泡图.setColor(Color.GREEN);
        mdatas.add(m气泡图);
        mBubbleChart=findView(R.id.chart);

        mBubbleData = new BubbleData(mdatas);
        mBubbleData.setDrawValues(true);
        mBubbleChart.setData(mBubbleData);
        mBubbleChart.invalidate();
    }
    @Override
    protected int getLayoutId() {
        return R.layout.buddlepage;
    }
}
